'use server';
import './index.css'
import React from 'react'
import QuestionDetail from '@/components/QuestionDetail'
import { queryQuestionVoByIdUsingGet } from '@/api/QuestionApi'

/**
 * 题目详情
 * @constructor
 */
export default async function QuestionPage({ params }) {
  const { questionId } = params;

  // 获取题目详情
  let question = undefined;
  try {
    const questionRes = await queryQuestionVoByIdUsingGet({
      id: questionId,
    });
    question = questionRes.data;
  } catch (e) {
    console.log('获取题目详情失败' + e);
  }

  if (!question) {
    return <div>获取题目详情失败，请刷新重试</div>;
  }

  return (
    <div id="bank-question-page">
      <QuestionDetail question={question} />
    </div>
  );
}
